<?php
	defined('_JEXEC') or die('Restricted access');
	require_once(CUTEENGINE_BASE_COMPONENTS_PATH."base_display_component_class.php");
    //
    // t_component_configurator

    //
	class t_component_configurator extends t_base_display_component
	{	
		// property
		// public		
		// C
		public $content_loader = null;
		const language_position_last = 1;
		// S
        const specific_parameters_position_last = 1;
		
		// method
		// protected
		//C
		protected function create_tags_structure()
		{
			global $g_javascript_namespace;            
            
            // javascript
			// C
            //
            if (! $this->main_tag)
			{
                
				$this->main_tag = new t_base_tag(t_base_tag_type::btt_div,$this->name);

				$local_header_script_generator = $this->main_tag->header_script_generator;
				//
                $this->main_tag->include_child_str = true;
                $local_header_script_generator->add_style_sheet_property("#$this->name","display","inline-block");
				$local_header_script_generator->add_style_sheet_property("#$this->name",'position','relative');
				$local_header_script_generator->add_style_sheet_property("#$this->name",'background-color','Lavender');
				$local_header_script_generator->add_style_sheet_property("#$this->name",'border','1px solid blue');
				$this->main_tag->set_editing_tags(true);
                //
				//$this->compute_tags_structure();
                if ($this->use_log)
                {
                    $this->main_tag->create_and_add_child_at_bottom(t_base_tag_type::btt_div,parent::get_log_tag_name());
                }    
                /* */
                
			}
		}
        // G
		public function get_language_position_last()
        {
            return self::language_position_last;
        }
        static function get_help_specific_parameter($a_index)
		{
			$local_return = 'NO HELP AVAILABLE';
			/*switch ($a_index) 
            {
                case self::specific_parameters_position_:
					$local_return = '';
				break;                
			}*/
			return $local_return;
		}
        static function get_default_specific_parameter($a_index)
		{
			$local_return = '';
			//echo "a_index: $a_index<br>";
			switch ($a_index) 
            {
                /*case self::specific_parameters_position_:
					$local_return = 'TRUE';
				break;                */
			}
			return $local_return;
		}
        protected function get_specific_parameters_position_last()
        {
            return self::specific_parameters_position_last;
        }
		// I
		protected function initialize_query_parameters()
		{
		    
		}
		// public
		public function __construct($a_cuteengine_component,$a_query_parameter) 
		{
			global $g_javascript_namespace;
			$this->use_log = false;
			$this->content_loader = new t_content_loader($g_javascript_namespace,$this);
			$this->content_loader->initialize_parameter('undefined',
				'undefined','undefined','undefined',
				'undefined','undefined',false);
			
            parent::__construct($a_cuteengine_component,$a_query_parameter);
			$this->content_loader->component_to_log = $this->get_log_tag_name();
			
		}	
		// C
		public function create_internal_parts()
        {
			global $g_database_namespace;
            parent::create_internal_parts();
			//echo __METHOD__  . "<br>";
			// MAIN FORM
            $local_part = $this->add_new_part(-1,1,t_table_part,'@componets_grid@|true|true|true|true|true|true|true|true|@@',"@SELECT * from ".$g_database_namespace->main_table_name." order by ID @@",
				//field 1
				"@|t_field_grid|components_grid_tag|-1|grid|[]|@",
				// action 1
				'@["none","t_action_set_values_from_db","get_components_data",[' .
                '"","","components_grid_tag",""],"SELECT * from '.$g_database_namespace->main_table_name.' order by ID ",[],['.
				'],[]]@',1);  
           
			//
            // PARTS GRID
            $local_part = $this->add_new_part(-2,2,t_table_part,'@parts_grid@|false|true|true|true|true|true|true|true|@componets_grid@','@SELECT * from '.$g_database_namespace->parts_table_name.' WHERE `component_id` = :component_id:@@',
				//field 1
				'@|t_field_grid|parts_grid_tag|-1|grid|[]|@',
				// action 1
				'@["none","t_action_set_values_from_db","get_parts_data",['.
                '"","","parts_grid_tag",""],"SELECT * from '.$g_database_namespace->parts_table_name.' WHERE `component_id` = :component_id:",[],['.
				'""],[""]]@',1);        
        }
		
		//D
	/*	public function display_component()
		{
			parent::display_component();
		}*/
		// E
		public function execute_component_action()
		{
			$local_function = parent::execute_component_action();
            if ($local_function)
			{
				$this->$local_function();
            }
			else
			{
				 
			}
			//echo "argomento: ".$this->url_argument(self::main_url_argument_import_file_name);
			//$this->parse_source();
		}
        // G
        /*public function get_json_condition_values()
        {
            global $g_url_parameters_namespace;
			$local_parameter = $g_url_parameters_namespace->get_parameter_by_position(0);
			//echo "local_parameter->argument:$local_parameter->argument<br>";
			
			if ($local_parameter)
			{
			    $local_array = explode(t_url_parameter::separator_level_1,$local_parameter->argument);
			}
			else
            {
				$local_array = array();
  //              
            }    
            return str_replace('\/','/',json_encode($local_array));
		
        }*/
	}
?>